//
//  LYResumePayTypeCell.m
//  SelectCity
//
//  Created by liuyan on 2019/3/28.
//  Copyright © 2019年 liuyan. All rights reserved.
//

#import "LYResumePayTypeCell.h"

@interface LYResumePayTypeCell()

@property (nonatomic, strong) UIImageView *iconImage;
@property (nonatomic, strong) UIImageView *selectImage;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *detailLabel;

@end

@implementation LYResumePayTypeCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if ([super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self initSubViews];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}

#pragma mark - InitSubViews
- (void)initSubViews{
    self.selectImage = [[UIImageView alloc] initWithFrame:CGRectMake(WIDTH -25, 25, 15, 15)];
    [self.contentView addSubview:self.selectImage];
    
    self.iconImage = [[UIImageView alloc] initWithFrame:CGRectMake(15, 10, 45, 45)];
    self.iconImage.backgroundColor = [UIColor redColor];
    self.iconImage.layer.cornerRadius = 8;
    self.iconImage.clipsToBounds = YES;
    [self.contentView addSubview:self.iconImage];
    
    self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.iconImage.right + 5, 13, self.selectImage.left - self.iconImage.right -10, 20)];
    self.titleLabel.font = [UIFont systemFontOfSize:13];
    self.titleLabel.textColor = RGB(34, 34, 34);
    [self.contentView addSubview:self.titleLabel];
    
    self.detailLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.titleLabel.left, self.titleLabel.bottom+5, self.titleLabel.width, 20)];
    self.detailLabel.font = [UIFont systemFontOfSize:12];
    self.detailLabel.textColor = RGB(153, 153, 153);
    [self.contentView addSubview:self.detailLabel];
    
    UIView *lineview = [[UIView alloc] initWithFrame:CGRectMake(0, 64, WIDTH, 1)];
    lineview.backgroundColor = RGB(247, 247, 247);
    [self.contentView addSubview:lineview];
}

-(void)setModel:(LYResumePaytypeModel *)model{
    if (model.isSelected) {
        _selectImage.image = [UIImage imageNamed:@"privacysetting_main_s"];
    }else{
        _selectImage.image = [UIImage imageNamed:@"privacysetting_main_n"];
    }
    
    if ([model.type isEqualToString:@"1"]) {
        //微信
        _titleLabel.text = @"微信zf";
        _detailLabel.text = @"推荐已经在微信中绑定银行卡的用户使用";
        _iconImage.image = [UIImage imageNamed:@"zhifu-weixin"];
    }else if([model.type isEqualToString:@"2"]){
        //zfb
        _titleLabel.text = @"zfbzf";
        _detailLabel.text = @"推荐已经下载zfb客户端的用户使用";
        _iconImage.image = [UIImage imageNamed:@"zhifu-zhifubao"];
    }else{
        //余额
        _titleLabel.text = @"钱包支付";
        _iconImage.image = [UIImage imageNamed:@"zhifu-qianbao"];
        NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"您的个人账户余额："];
        NSAttributedString *strq = [[NSAttributedString alloc] initWithString:[UIToolsControl showAmount:[NSString stringWithFormat:@"%.2f",model.balance]] attributes:@{NSForegroundColorAttributeName :[UIColor orangeColor],NSFontAttributeName : [UIFont systemFontOfSize:12]}];
        [str appendAttributedString:strq];
        NSAttributedString *strq1 = [[NSAttributedString alloc] initWithString:@"元" attributes:@{NSForegroundColorAttributeName :RGB(153, 153, 153),NSFontAttributeName : [UIFont systemFontOfSize:12]}];
        [str appendAttributedString:strq1];
        
        _detailLabel.attributedText = str;
    }
}

@end
